<?php
/**
 * 币种管理
 */
namespace app\common\model;

use think\Model;

class Currency extends Model
{
    protected $name = 'currency';

    /**
     * 根据条件查询所有币种
     * @param array $where
     * @return mixed
     */
    public static function getAll($where = []){
        return self::where($where)->select();
    }

    /**
     * 查询用户使用中的币种
     * @return Currency[]|array|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public static function member_currency(){
        return self::where('status',2)->where('status',1)->select();
    }

    /**
     * 查询当个币种详情
     * @param $id 币种ID
     * @return Currency|array|mixed|Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public static function getDetails($id){
        return self::where('id',$id)->find();
    }

    /**
     * 根据字段名查询对应的数据
     * @param $fieldName 字段名称
     * @param $name 值
     */
    public static function getDetailsName($fieldName,$name){
        return self::where($fieldName,$name)->where('status',1)->find();
    }

}